<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>物料出库编辑</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" href="../css/mui.picker.min.css">
    <style type="text/css">
        .detail {
            padding-right: 20px!important;
        }

        h5 {
            color: #0062CC;
        }

        .mui-navigate-right .mui-col-xs-8 {
            width: 62.666667%!important;
        }

        .mui-text-right input,
        .mui-text-right textarea {
            border: 0;
            font-size: 14px;
            font-weight: 400;
            color: #8f8f94;
            margin-bottom: 0;
            text-align: right;
        }

        .flex_first {
            display: flex;
            align-items: flex-start;
        }

        .padding_r_18 {
            padding: 0 16px 0 0;
        }
    </style>
</head>

<body>
    <div class="mui-content content-padded_bottom">
        <ul class="mui-table-view mui-table-view-chevron">
        	<li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">SGMW ID：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="itemnum"></span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail" onclick="openSelStock()">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">库存地址：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="binnum"></span>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="mui-table-view mui-table-view-chevron type_list_spair">
            <li class="mui-table-view-cell detail" onclick="openSaveWin('work_order_sel_order','选择工单')">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">工单：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="refwo">请选择工单</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">状态：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span id="stauts" class="mui-h5"></span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">位置：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="address"></span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">交易类型：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <select class="mui-h5" style="direction:rtl;margin:auto;padding: 0;" id="issuetype">
                           <option value="发放">发放</option>
                           <option value="退回">退回</option>
                         </select>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="mui-table-view mui-table-view-chevron type_list_spair">
            <li class="mui-table-view-cell detail" onclick="openSelManager()">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">领料人：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="issuerto">请选择领料人</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">姓名：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="issuertoName"></span>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="mui-table-view mui-table-view-chevron type_list_spair">
            <li class="mui-table-view-cell detail" onclick="chooseTime('measure')">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">发放日期：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="actualdate">请选择日期</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">发放数量：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right no_padding">
                        <input type="number" placeholder="请输入数量" id="quantity"/>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table flex_first">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">描述：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <textarea class="padding_r_16" id="description" name="" rows="" cols="" placeholder="请输入描述"></textarea>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/mui.picker.min.js"></script>
<script type="text/javascript">
    var invbalancesid,matusetransid;
    apiready = function() {
        onLoadData();
        api.parseTapmode();
	    api.addEventListener({
	        name: 'selOrder'
	    }, function(ret, err) {
	    	refwo = ret.value.selOrderId;
	       $api.html($api.byId('refwo'),ret.value.selOrderId);
	       $api.html($api.byId('stauts'),ret.value.selOrderStatus);
	       $api.html($api.byId('address'),ret.value.selOrderAddress);
	    })
	    api.addEventListener({
	        name: 'ManagerCh'
	    }, function(ret, err) {
	       $api.html($api.byId('issuerto'),ret.value.userID);
	       $api.html($api.byId('issuertoName'),ret.value.userName);
	    })
        api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'right') {
                    if (!$api.text($api.byId('refwo'))) {
                        Toast('请选择工单！');
                        return
                    }
                    if (!$api.text($api.byId('issuerto'))) {
                        Toast('请选择领料人！');
                        return
                    }
                    if (!$api.text($api.byId('actualdate'))) {
                        Toast('请选择发放日期！');
                        return
                    }
                    if (!$api.val($api.byId('quantity'))) {
                        Toast('请输入数量！');
                        return
                    }
                    if ($api.val($api.byId('quantity')) < 0 ) {
                        Toast('数量必须大于0！');
                        return
                    }
                    ajaxrd("updateCheckOut", {
                        invbalancesid: invbalancesid,
                        matusetransid: matusetransid,
                        refwo: $api.html($api.byId('refwo')),
                        storeloc: $api.html($api.byId('storeloc')),
                        issueto: $api.html($api.byId('issuerto')),
                        issuetype:$api.val($api.byId('issuetype')),
                        binnum: $api.html($api.byId('binnum')),
                        actualdate: $api.html($api.byId('actualdate')),
                        quantity: $api.val($api.byId('quantity')),
                        description: $api.val($api.byId('description'))
                    }, function(data) {
                        Toast('修改成功');
                        api.sendEvent({
	                        name: 'refersh',
	                        extra: {
	                            isrefersh: 'yes'
	                        }
	                    });
                        setTimeout(function() {
                            api.closeWin();
                        }, 100)
                    })
                }
        	})
    	api.parseTapmode();
    }

    function onLoadData() {
        ajaxrd("queryCheckOutDetail", {
            matusetransid: api.pageParam.matusetransid
        }, function(data) {
        	matusetransid = data.matusetransid;
        	invbalancesid = data.invbalancesid;
        	$api.html($api.byId('itemnum'), data.itemnum),
            $api.html($api.byId('refwo'), data.refwo),
            $api.html($api.byId('stauts'), data.status),
            $api.html($api.byId('storeloc'), data.storeloc),
            $api.val($api.byId('issuetype'), data.issuetype),
            $api.html($api.byId('issuerto'), data.issueto),
            $api.html($api.byId('issuertoName'), data.issuertoName),
            $api.html($api.byId('binnum'), data.binnum),
            $api.html($api.byId('actualdate'), data.actualdate),
            $api.val($api.byId('quantity'), Math.abs(data.quantity)),
            $api.val($api.byId('description'), data.description);
        })
    }

    function chooseTime(type) {
        selectCommonYMDhm(function(data) {
        	$api.html($api.byId('actualdate'),data)
        })
    }

    function openSelManager(){
	    openSaveWin('work_order_sel_manager','选择人员',{manager:true})
	}
</script>

</html>
